package com.force.provider;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sforce.soap.partner.QueryResult;
import com.sforce.soap.partner.SaveResult;
import com.sforce.soap.partner.sobject.SObject;
import com.sforce.ws.ConnectionException;

@Service
public class SalesForceServices {

	@Autowired
	private SalesForceConnectionProvider connectionProvider; 
	
	public QueryResult query (String query) throws ConnectionException {
		return connectionProvider.getPartnerConnection().query(query);
	}

	public QueryResult queryMore (String queryLocator) throws ConnectionException {
		return connectionProvider.getPartnerConnection().queryMore(queryLocator);
	}

	public SaveResult[] insert (List<SObject> values) throws ConnectionException {
		return connectionProvider.getPartnerConnection().create(values.toArray( new SObject[ values.size() ] ));
	}
	
	
	
}
